home *** CD-ROM | disk | FTP | other *** search
- #include <string.h>
- #include <io.h>
- #include <time.h>
- #include <dos.h>
- #include "pw.h"
-
- char myclass[] = "myclass";
- char timerclass[] = "timer";
- char dirclass[] = "dir";
- char name[] = "Window";
-
- struct NewWindow NewWindow0 = { 20,7,50,15,
- 0x57,0x5F,WNDSTYLE_BOLDBORDER,
- 0,
- name,
- myclass, 0 };
-
- struct NewWindow NewWindow1 = { 13,10,24,10,
- 0x1E,0x1F,WNDSTYLE_BORDER,
- 0,
- name,
- myclass, 0 };
-
- struct NewWindow NewWindow2 = { 50,1,14,15,
- 0x2E,0x2E,WNDSTYLE_BORDER,
- 0,
- name,
- dirclass, 0 };
-
- struct NewWindow NewWindow3 = { 20,12,22,3,
- 0x3F,0x3f,WNDSTYLE_BORDER,
- 0,
- name,
- timerclass, 0 };
-
- struct Window *win;
- struct Window *win1;
- struct Window *win2;
- struct Window *win3;
-
- struct find_t files[100];
- int index=0,count;
-
- long DirProc (struct Window *win, unsigned Message, int wParam, long lParam)
- {
- static int i;
- void GetDir ();
- char buffer[64],*ptr;
-
- switch (Message) {
- case WM_CREATE:
- GetDir ();
- index = 0;
- break;
-
- case WM_KEYPRESSED:
- if (lParam) {
- switch (wParam) {
- case 0x50:
- if (index==count) break;
- ScrollWindow (win,0,1);
- index++;
- OutText (win,0,0,files[index].name,strlen(files[index].name));
- break;
- case 0x48:
- if (!index) break;
- ScrollWindow (win,0,-1);
- OutText (win,0,12,files[index+12].name,strlen(files[index+12].name));
- index--;
- break;
- }
- }
- break;
-
- case WM_PAINT:
- for (i=0;i<13;i++) {
- ptr = strchr(files[i].name,'.');
- if (ptr) *ptr=0;
- sprintf (buffer,"%-8s .%s",files[i].name,ptr+1);
- OutText (win,0,i,buffer,strlen(buffer));
- }
- break;
- }
- return 0;
- }
-
- long WndProc (struct Window *win, unsigned Message, int wParam, long lParam)
- {
- return 0;
- }
-
- long TimeProc (struct Window *window, unsigned Message, int wParam, long lParam)
- {
- static int i=0,rx=1,ry=1,x=5,y=3;
- char Buffer[30];
- long mytime;
- static char *ptr=0;
-
- switch (Message) {
- case WM_TIMER:
- if (i++>17) {
- i = 0;
- time (&mytime);
- sprintf (Buffer,"%s",ctime(&mytime));
- OutText ( window,0,0,Buffer,strlen(Buffer));
- }
- OutText (win,x,y," ",4);
- if ((x+rx<0) || (x+rx==44)) rx = -rx;
- if ((y+ry<0) || (y+ry==13)) ry = -ry;
- x += rx;
- y += ry;
- OutText (win,x,y,"ATMO",4);
-
- ScrollWindow (win1,0,-1);
- sprintf (Buffer,"%0.2X %0.2X %0.2X %0.2X - %c%c%c%c",
- (char) *ptr,(char) *(ptr+1),(char) *(ptr+2),(char) *(ptr+3),
- *ptr ? *ptr : '.',
- *++ptr ? *ptr : '.',
- *++ptr ? *ptr : '.',
- *++ptr ? *ptr : '.');
- OutText (win1,2,7,Buffer,strlen(Buffer));
- break;
- }
- return 0;
- }
-
- void GetDir ()
- {
- struct find_t findbuffer;
-
- if (!_dos_findfirst ("*.*",_A_NORMAL,&findbuffer))
- do memcpy (&files[index++],&findbuffer,sizeof (struct find_t));
- while (!_dos_findnext (&findbuffer));
- count = index;
- }
-
- int WinMain ()
- {
- AddClass (myclass,WndProc);
- AddClass (timerclass,TimeProc);
- AddClass (dirclass,DirProc);
-
- win = CreateWindow (&NewWindow0);
- win1 = CreateWindow (&NewWindow1);
- win3 = CreateWindow (&NewWindow3);
- win2 = CreateWindow (&NewWindow2);
- SetTimer (win3,1);
-
- MainWindowProc ();
-
- DestroyWindow (win2);
- DestroyWindow (win3);
- DestroyWindow (win1);
- DestroyWindow (win);
-
- return 1;
- }
-